<?php
	require_once("../classes/Database.php");
	
	session_start();
	
	if(isset($_SESSION["ad"])){
		$ad = $_SESSION["ad"];
		unset($_SESSION["ad"]);
		
		$db = new Database("localhost", "root", "");
		$db->connect("emprego");
		$db->executeQuery("SELECT owner FROM announcement WHERE id=$ad");
		$line = $db->getResultLine(MYSQL_ASSOC);
		
		$db->executeQuery("DELETE FROM announcement WHERE id=$ad");
		$db->disconnect();
	}
	
	header("Location: searchAnnouncement.php?enterprise=".$line["owner"]);
?>